Chained Variants Parameter Exploration
This example demonstrates exploring the parameter space by chaining .variants() calls. Each .variants() adds a dimension, and .run() automatically explores all combinations.
Code Example
from sigexec import Graph
from sigexec.blocks import LFMGenerator, StackPulses, RangeCompress, DopplerCompress
# Build graph and chain variants
results = (Graph("Radar")
.add(LFMGenerator(num_pulses=64, target_delay=2e-6, target_doppler=200.0))
.add(StackPulses())
.variants(lambda w: RangeCompress(window=w, oversample_factor=2),
['hamming', 'hann', 'blackman'],
names=['Hamming', 'Hann', 'Blackman'])
.variants(lambda w: DopplerCompress(window=w, oversample_factor=2),
['hamming', 'hann'],
names=['Hamming', 'Hann'])
.run()
)
# Results is a list of (params_dict, result_data) tuples
# 3 range windows × 2 doppler windows = 6 total combinations
for params, result in results:
# Access variants as a list: params['variant'][0], params['variant'][1], etc.
print(f"Range: {params['variant'][0]}, Doppler: {params['variant'][1]}")
print(f" Peak SNR: {calculate_snr(result):.1f} dB")
Parameter Sweep Results
Testing all combinations of window functions: - Range Compression: hamming, hann, blackman - Doppler Compression: hamming, hann Total combinations: 3 × 2 = 6
| Range Window | Doppler Window | Peak SNR (dB) | Peak Location |
|---|---|---|---|
| hamming | hamming | 57.1 | (np.int64(90), np.int64(20)) |
| hamming | hann | 56.9 | (np.int64(90), np.int64(20)) |
| hann | hamming | 56.8 | (np.int64(90), np.int64(20)) |
| hann | hann | 56.4 | (np.int64(90), np.int64(20)) |
| blackman | hamming | 56.1 | (np.int64(90), np.int64(20)) |
| blackman | hann | 55.8 | (np.int64(90), np.int64(20)) |
Range: hamming, Doppler: hamming
Range: hamming, Doppler: hann
Range: hann, Doppler: hamming
Range: hann, Doppler: hann
Range: blackman, Doppler: hamming
Range: blackman, Doppler: hann
Summary
Chaining .variants() allows you to: 1. Automatically try all combinations of parameters 2. Compare results systematically 3. Find optimal parameter settings 4. Understand parameter interactions The graph uses memoization, so common stages (like signal generation and stacking) only execute once and are reused across all variants.